<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ page import="net.fckeditor.*"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.List"%>
<%@page import="com.travelsky.airchina.boarding.domain.NewsColumn"%>
<%@page import="com.travelsky.airchina.boarding.common.ConstType"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>管理中心 - 查看新闻</title>
	<%@ include file="/common/meta.jsp" %>
	<link href="${ctx}/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/main.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/category.css" rel="stylesheet" type="text/css" />	
	<script type="text/javascript" src="${ctx}/js/checkFrameSet.js"></script>
	<script type="text/javascript" src="${ctx}/js/jquery-1.4.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/operationTip.js"></script>
	<script language="JavaScript">
	 function previewNews(htmlUrl){
	    window.open("${ctx}<%=ConstType.NEWS_HTML_PATH%>"+htmlUrl);
	 }
	</script>
	<%
		FCKeditor fckEditor = new FCKeditor(request, "content");
		fckEditor.setHeight("560");
		String content = (String)request.getAttribute("content");
		fckEditor.setValue(content!=null?content:"");
	%>
</head>
<body>
<h1>
<span class="action-span"><a href="${ctx}/system/news/manage">新闻列表</a></span>
<span class="action-span1"><a href="#">管理中心</a>  - 查看新闻 </span>
<div style="clear:both"></div>
</h1>
<%
String operationFlag = (String)request.getAttribute("operationFlag");
if(operationFlag!=null){
   if("t".equals(operationFlag)){
%>
  <ul class="actionMessage">
    <li>操作成功
    </li>
  </ul>
<%
   }else if("f".equals(operationFlag)){
%>
  <ul class="errorMessage">
    <li>操作失败
    </li>
  </ul>
<%
   }
}
%>
<div class="main-div">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">新闻标题</td>
        <td>
          <input name="title" maxlength="100" size="50" value="${news.title}" /> <font color="red">*</font> </td>
      </tr>
      <tr>
        <td class="label">新闻副标题</td>
        <td><input name="subtitle" maxlength="100" size="50" value="${news.subtitle}" /></td>
      </tr>
      <tr>
        <td class="label">新闻作者</td>
        <td><input name="author" maxlength="20" size="50" value="${news.author}" /></td>
      </tr>
      <tr>
        <td class="label">新闻来源</td>
        <td><input name="source" maxlength="100" size="50" value="${news.source}" /></td>
      </tr>
      <tr>
        <td class="label">新闻栏目</td>
        <td>
	       <div class="cascading-container">
		    <ol id="J_OlCascadingList">
		      <li id="l_1" class="root">
		        <ul id="u_1">
		           <c:if test="${rootNewsColumns!=null}">
			           <c:forEach items="${rootNewsColumns}" var="itemTemp">
			             <c:choose>
			                <c:when test="${itemTemp.isLeaf==0}">
					           <c:choose>
					             <c:when test="${rootNewsColumnId==itemTemp.id}">
			           <li id="${itemTemp.id}" class="parent selected"><span>${itemTemp.name}</span></li>
					             </c:when>
					             <c:otherwise>
			           <li id="${itemTemp.id}" class="parent"><span>${itemTemp.name}</span></li>
					             </c:otherwise>
					           </c:choose>
			                </c:when>
			                <c:otherwise>
					           <c:choose>
					             <c:when test="${rootNewsColumnId==itemTemp.id}">
			           <li id="${itemTemp.id}" class="selected"><span>${itemTemp.name}</span></li>
					             </c:when>
					             <c:otherwise>
			           <li id="${itemTemp.id}"><span>${itemTemp.name}</span></li>
					             </c:otherwise>
					           </c:choose>
			                </c:otherwise>
			             </c:choose>
			           </c:forEach>
		           </c:if>
		        </ul>
		      </li>
		      
		      <%
		      @SuppressWarnings("unchecked")
		      List<Long> cateIdList = (List<Long>)request.getAttribute("newsColumnIds");
		      Long newsColumnId = (Long)request.getAttribute("newsColumnId");
		      @SuppressWarnings("unchecked")
		      Map<Long,List<NewsColumn>> parentCateListMap = (Map<Long,List<NewsColumn>>)request.getAttribute("map");
		      if(parentCateListMap!=null && parentCateListMap.keySet().size()>0){
		         int liIndex = 0;
		         for(Long pId:parentCateListMap.keySet()){
		            liIndex++;
		       %>
		                <li id="_o_l_<%=liIndex%>">
		                  <ul id="_o_l_u_<%=liIndex%>">
		       <%
		            List<NewsColumn> cateList = parentCateListMap.get(pId);
		            for(NewsColumn cate:cateList){
		                     if("0".equals(cate.getIsLeaf())){
		                        if(cateIdList.contains(cate.getId())){
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent selected"><span><%=cate.getName()%></span></li>
		                    <%
		                        }else{
		                           if(cate.getId().equals(newsColumnId)){
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent selected"><span><%=cate.getName()%></span></li>
		                    <%
		                           }else{
		                    %>
		                    <li id="<%=cate.getId()%>" class="parent"><span><%=cate.getName()%></span></li>
		                    <%
		                           }
		                        }
		                     }else{
		                        if(cateIdList.contains(cate.getId())){
		                    %>
		                    <li id="<%=cate.getId()%>" class="selected"><span><%=cate.getName()%></span></li>
		                    <%
		                        }else{
		                           if(cate.getId().equals(newsColumnId)){
		                    %>
		                    <li id="<%=cate.getId()%>" class="selected"><span><%=cate.getName()%></span></li>
		                    <%
		                           }else{
		                    %>
		                    <li id="<%=cate.getId()%>"><span><%=cate.getName()%></span></li>
		                    <%
		                           }
		                        }
		                     }
		          }
		      %>
		                  </ul>
		                </li>
		      <%
		         }
		      }
		      %>
		    </ol>
		  </div>
        </td>
      </tr>

      <c:choose>
         <c:when test="${not empty news.imageFile}">
      <tr id="imageTextDiv">
        <td class="label">新闻图片</td>
        <td>
          <input type="file" id="image" name="image"/>
        </td>
      </tr>
      <tr>
        <td class="label"></td>
        <td>
           <img src="${ctx}${NEWS_IMAGE_PATH}/${news.imageFile}"/>
        </td>
      </tr>
         </c:when>
      </c:choose>
      
      <tr>
        <td class="label">排序</td>
        <td>
          <input name="sortOrder" size="15" value="${news.sortOrder}" /></td>
      </tr>

      <tr>
        <td class="label">描述</td>
        <td>
        <%out.println(fckEditor);%>
        </td>
      </tr>
      </table>
      <div class="button-div">
        <input type="button" onclick="javascrpt:previewNews('${news.htmlUrl}')" value=" 预览 " />
      </div>
</div>
</body>
</html>